<template>
	<view class="userinfo-container">
		<view class="top-box">
			<image :src="userInfo.avatarUrl" class="avatar"></image>
			<view class="nickname">{{userInfo.nickName}}</view>
		</view>
		<view class="panel-list">
			<view class="panel">
				<view class="panel-body">
					<view class="panel-item">
						<text>8</text>
						<text>收藏的店铺</text>
					</view>
				</view>
				<view class="panel-body">
					<view class="panel-item">
						<text>8</text>
						<text>收藏的商品</text>
					</view>
				</view>
				<view class="panel-body">
					<view class="panel-item">
						<text>8</text>
						<text>关注的商品</text>
					</view>
				</view>
				<view class="panel-body">
					<view class="panel-item">
						<text>8</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			<view class="panel-2">
				<view class="panel-title">
					我的订单
				</view>
				<view class="panel-body">
					<view class="panel-item">
						<image src="/static/icon1.png"></image>
						<text>待付款</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon2.png"></image>
						<text>待收货</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon3.png"></image>
						<text>退货退款</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon4.png"></image>
						<text>全部订单</text>
					</view>
				</view>

			</view>
			<view class="panel-3">
				<view class="panel-item">
					<text>收货地址</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view class="panel-item">
					<text>联系客服</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view @click="loginout" class="panel-item">
					<text>退出登录</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>

			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapMutations,
		mapGetters,
		mapState
	} from 'vuex'
	export default {
		data() {
			return {

			};
		},
		computed: {
			...mapState('user', ['userInfo'])
		},
		methods: {
			...mapMutations('user',['updateUserInfo','updateAddress','updatetoken']),
			async loginout() {
				const res = await uni.showModal({
					title: '提示',
					content: '确认退出登录？'
				})
				if(res.confirm){
					this.updateUserInfo({}),
					this.updateAddress({}),
					this.updatetoken("")
				}
			}
		}
	}
</script>
<style lang="scss">
	.panel-list {
		padding: 0 10px;
		transform: translateY(-20px);

		.panel {
			border-radius: 3px;
			background-color: #FFF;
			margin-top: 8px;
			display: flex;
			justify-content: space-around;

			.panel-body {
				.panel-item {
					display: flex;
					justify-content: center;
					align-items: center;
					flex-direction: column;
				}
			}
		}

		.panel-2 {
			border-radius: 3px;
			background-color: #FFF;
			margin-top: 8px;

			.panel-title {
				line-height: 45px;
				padding-left: 10px;
				font-size: 15px;
				border-bottom: 1px solid #F4F4F4;
			}

			.panel-body {
				display: flex;
				justify-content: space-around;
			}

			.panel-item {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				image {
					width: 35px;
					height: 35px;
				}
			}
		}

		.panel-3 {
			border-radius: 3px;
			background-color: #FFF;
			margin-top: 8px;

			.panel-item {
				border-bottom: 2px solid #FFF;
				display: flex;
				justify-content: space-between;
				line-height: 45px;
				padding: 0 10px;
			}
		}
	}

	.userinfo-container {
		height: 100%;
		background-color: #F4F4F4;

		.top-box {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			height: 400rpx;
			background-color: red;

			.avatar {
				width: 90px;
				height: 90px;
				border-radius: 45px;
				border: 2px solid #FFF;
				box-shadow: 0 1px 5px black;
			}

			.nickname {
				font-size: 16px;
				color: #FFF;
				font-weight: bold;
				margin-top: 10px;
			}
		}
	}
</style>